/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.easoftware.code.beans.maintenance.navigator;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import net.easoftware.code.beans.BeanHelper;
import net.easoftware.code.beans.ComboItem;
import org.apache.log4j.Logger;

/**
 *
 * @author Eliu
 */
@Named
@SessionScoped
public class MbNavigator implements Serializable {

    private final static Logger logger = org.apache.log4j.Logger.getLogger(MbNavigator.class);
    private NavigatorConfig configuration;
    private List<ComboItem> navigatorTypes;
    private String navigator;

    public void loadNavigator() {
        try {
            configuration = (NavigatorConfig) BeanHelper.findBean(getNavigator());
            logger.info("Cargando configuracion: " + configuration.getTitle());
        }
        catch (Exception ex) {
            logger.error(ex);
        }
    }

    public String getNavigator() {
        return navigator;
    }

    public void setNavigator(String navigator) {
        this.navigator = navigator;
    }

    public List<ComboItem> getNavigatorTypes() {
        if (navigatorTypes == null || navigatorTypes.isEmpty()) {
            navigatorTypes = new LinkedList<>();
            navigatorTypes.add(new ComboItem("ChequesRechazadosNav", "Navegacion Cheques Rechazados"));
            navigatorTypes.add(new ComboItem("AsOffNav", "Navegacion AsOff"));
            navigatorTypes.add(new ComboItem("OrdenesNav", "Navegacion Ordenes"));
            navigatorTypes.add(new ComboItem("OrdenesRetNav", "Navegacion Ordenes Retenidas"));
            navigatorTypes.add(new ComboItem("VentasNav", "Navegacion Ventas"));
        }

        return navigatorTypes;
    }

    public void setNavigatorTypes(List<ComboItem> navigatorTypes) {
        this.navigatorTypes = navigatorTypes;
    }

    public NavigatorConfig getConfiguration() {
        return configuration;
    }

    public void setConfiguration(NavigatorConfig configuration) {
        this.configuration = configuration;
    }

    public void doSelect(String attr, Object value) {
        logger.info("Delegando doSelect a implementacion...");
        configuration.doSelect(attr, value);
    }
    
    
}
